CC:=gcc
CFLAGS := -g -O0 -Wall  # 添加调试信息并禁用优化


log:=thirdparty/log.c thirdparty/log.h

test_log:  test/test_log.c $(log)
	$(CC) -o $@ $^ -Ithirdparty
	./test_log
	rm -f test_log

json:=thirdparty/cJSON.c thirdparty/cJSON.h
test_json: test/test_json.c $(json) $(log)
	$(CC) $(CFLAGS) -o $@ $^ -Ithirdparty
#	./test_json
#	rm -f test_json


app_common:=app/app_common.c app/app_common.h
test_common: test/test_common.c $(app_common) $(log)
	$(CC) -o $@ $^ -Ithirdparty -Iapp
	./test_common
	rm -f test_common


app_pool:=app/app_pool.c app/app_pool.h
test_pool: test/test_pool.c $(app_pool) $(log)
	$(CC) -o $@ $^ -Ithirdparty -Iapp
	./test_pool


app_mqtt:=app/app_mqtt.c app/app_mqtt.h
test_mqtt: test/test_mqtt.c $(app_mqtt) $(log)
	-$(CC) -o $@ $^ -Ithirdparty -Iapp -lpaho-mqtt3c
	-./test_mqtt
	rm -f test_mqtt

app_message:=app/app_message.c app/app_message.h
test_message: test/test_message.c $(app_message)  $(json) $(app_common) $(log)
	$(CC)  $(CFLAGS) -o $@ $^ -Ithirdparty -Iapp

app_buffer:=app/app_buffer.c app/app_buffer.h
test_buff: test/test_buff.c $(app_buffer) $(log)
	$(CC)  $(CFLAGS) -o $@ $^ -Ithirdparty -Iapp
	./test_buff
	rm -f test_buff
	
	./test_message
	rm -f test_message

app_device:=app/app_device.c app/app_device.h
test_device: test/test_device.c $(app_device) $(log) $(app_buffer) $(app_message) $(app_common) $(json) $(app_pool) $(app_mqtt) $(app_message) 
	-$(CC) $(CFLAGS)  -o $@ $^ -Ithirdparty -Iapp	 -lpaho-mqtt3c
	-./test_device
	rm -f test_device